package com.baitiaojun.video.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.*;

/**
 * @类名 AsyncConfig
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2022/12/31 17:14
 * @版本 1.0
 */
@EnableAsync
@Configuration
public class AsyncConfig implements AsyncConfigurer {

    @Override
    public ThreadPoolExecutor getAsyncExecutor() {
        return new ThreadPoolExecutor(
                10,
                50,
                30000,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1000),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }
}
